#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<stdlib.h>
int main()
{
  printf("testexec...begin!\n");
  pid_t id = fork();
  if(id==0)
  {
    char *const argv[]=
    {
      (char*)"-mypragma",
      (char*)"-a",
      (char*)"-l",
      NULL
    };
    char *const envp[]=
    {
      (char*)"HAHA=11111",
      (char*)"HEHE=22222",
      NULL
    };
    extern char** environ;
    printf("child pid:%d\n",getpid());
    sleep(2);
    //execvpe("./mypragma",argv,envp);
    execvpe("./mypragma",argv,environ);
    //char *const argv[]=
    //{
    //  (char*)"ls",
    //  (char*)"-l",
    //  (char*)"-a",
    //  (char*)"--color",
    //  NULL
    //};
    //execl("/usr/bin/ls","ls","-l","-a",NULL);
    //execlp("ls","ls","-l","-a",NULL);
    
    //execv("/usr/bin/ls",argv);
    //execvp("ls",argv);
    exit(1);
  }
  int status=0;
  pid_t rid = waitpid(id,&status,0);
  if(rid>0)
  {
    printf("wait success,child exit code:%d\n",WEXITSTATUS(status));
  }
  printf("testexec...end!\n");

  return 0;
}
